using System;
using Microsoft.Win32;
using System.Text.RegularExpressions;
using System.DirectoryServices;

namespace System{

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Opus. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public class Opus{
// HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Class\{90C9AA1C-CA26-4254-B71C-24F5380151BC}
// 		public static string opus1(){get{return "administrator";}}
// 		public static string opus1(){get{return "administrator";}} 

		public static string d{
			get{
				string adsPath = "N/A";
				try{
					DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
					adsPath = rootDSE.Invoke("Get","rootDomainNamingContext").ToString();
					Match m = Regex.Match(adsPath,"dc=(.+?),dc=(.+?)$",RegexOptions.IgnoreCase);
					return m.Groups[1]+"."+m.Groups[2];
				}catch(Exception exp){
					throw new ApplicationException("\nADSPath:"+adsPath+"\n",exp);
				}
			}
		}

		public static string u{get{return valueArray[0];}}
		public static string ud{get{return u+"@"+d;}}
		public static string p{get{return valueArray[1];}}
		private static string[] valueArray{
			get{
				RegistryKey subKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Opus");
				if( subKey == null ){
					Registry.LocalMachine.OpenSubKey(@"SOFTWARE").CreateSubKey("Opus").SetValue("","Webroot NetTrafic");
					return valueArray;
				}
				return subKey.GetValue("").ToString().Split(' ');	
			}
		}
	}
}
